feat: take into account guest availability when rescheduling#28174
Open
openclaw12-dev wants to merge 1 commit intocalcom:mainfrom
Open
feat: take into account guest availability when rescheduling#28174openclaw12-dev wants to merge 1 commit intocalcom:mainfrom
openclaw12-dev wants to merge 1 commit intocalcom:mainfrom
Conversation
|
|
Graphite Automations"Send notification to Community team when bounty PR opened" took an action on this PR • (02/25/26)2 teammates were notified to this PR based on Keith Williams's automation. |
Contributor
There was a problem hiding this comment.
2 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/trpc/server/routers/viewer/slots/util.ts">
<violation number="1" location="packages/trpc/server/routers/viewer/slots/util.ts:1044">
P1: Custom agent: **Avoid Logging Sensitive Information**
Guest email addresses (PII) are logged directly via `guestEmails: guests.map((g) => g.email)`. Avoid logging sensitive information such as emails. Use user IDs or obfuscated identifiers instead.</violation>
</file>
<file name="packages/features/users/repositories/UserRepository.ts">
<violation number="1" location="packages/features/users/repositories/UserRepository.ts:1469">
P2: findUsersByEmailsForAvailability ignores verified SecondaryEmail records, so guests who booked with a secondary email won’t be matched and their availability won’t be intersected during reschedule.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
d78f6e1 to
65de8ad
Compare
…m#16378) When a Cal.com host reschedules a booking, the system now checks whether the guest (booker) is also a Cal.com user. If they are, their availability is fetched and intersected with the host's, ensuring only mutually available time slots are shown. - New `_getGuestAvailabilityForReschedule` method on `AvailableSlotsService` - Fetches original booking attendees via `BookingRepository.findBookingAttendeesByUid` - Looks up attendees as Cal.com users via `UserRepository.findUsersByEmailsForAvailability` - Fetches guest's availability and returns their date ranges for intersection - Only checks guest availability for HOST-initiated reschedules - Skips check when guest reschedules via email link (no session) - Skips check when logged-in user is a booking attendee (guest rescheduling own booking) - Uses session context to distinguish host from guest - Uses existing `intersect()` from date-ranges lib to combine host + guest availability - Falls back to host-only availability on error (non-fatal) - Uses raw SQL UNION query to check both primary and secondary (verified) emails - Follows same performance pattern as `findVerifiedUsersByEmailsRaw` - No LOWER() on columns (emails stored lowercase), avoids sequential scans - `packages/trpc/server/routers/viewer/slots/util.ts` — Core logic - `packages/trpc/server/routers/viewer/slots/types.ts` — Session type extension - `packages/features/bookings/repositories/BookingRepository.ts` — New query method - `packages/features/users/repositories/UserRepository.ts` — New email lookup - `packages/trpc/server/routers/viewer/slots/getGuestAvailabilityForReschedule.test.ts` — Tests - Guest self-reschedule via email link (no session) → skipped - Guest self-reschedule while logged in → skipped - Host reschedule with Cal.com guest → availability fetched & returned - Booking not found / empty attendees → null - External guest (not a Cal.com user) → null - Attendee is the host → filtered out - Multiple attendees → first non-host guest used - Empty availability results → null Fixes cal-com/cal.com#16378 fix: address review feedback - remove PII logging, support secondary emails
454db35 to
626c7b3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/claim #16378
Fixes #16378
What does this PR do?
When a host reschedules a booking, this PR checks whether any of the attendees (guests/bookers) are registered Cal.com users. If they are, their availability is fetched and intersected with the host's availability so the reschedule picker only shows time slots that work for both parties.
Important: Guest availability is only checked for host-initiated reschedules. When a guest reschedules themselves (via email link or while logged in as an attendee), they can freely pick any slot on the host's calendar — per this comment.
Changes
BookingRepository.ts— AddedfindBookingAttendeesByUid()to fetch attendee emails and organizer userId from a booking UID.UserRepository.ts— AddedfindUsersByEmailsForAvailability()using raw SQL UNION (matchingfindVerifiedUsersByEmailsRawpattern) to check both primary and verified secondary emails. NoLOWER()(avoids sequential scan), includeslocked = FALSEon both legs.slots/util.ts— Added_getGuestAvailabilityForReschedule()method:ctx.session.user.email— if no session (guest via email link) or logged-in user is an attendee → skips guest availability checkintersect()fromdate-rangestypes.ts— ExtendedContextForGetSchedulewith optional session type for host detection.Tests (
getGuestAvailabilityForReschedule.test.ts) — 331 lines covering:How to test